﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Net.Sockets;
using System.Collections;

namespace ChatRoom
{
    public partial class Admin : Form
    {
        Hashtable clients = new Hashtable();
        public Admin()
        {
            InitializeComponent();
            this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            timer1.Start();
            
            //lvwClients.Items.Add(listyviewsy);
            //test patch
            
        }

        private void timer1_Tick(object sender, System.EventArgs e)
        {

        }

        private void refresh()
        {
            int i = 1;
            if (this.InvokeRequired)
            {
                this.Invoke(new MethodInvoker(this.refresh));
            }
            while (true)
            {
                ListViewItem LVI = new ListViewItem("Track " + i);
                LVI.SubItems.Add("Updated");
                lvwClients.Items.Add(LVI);
                lvwClients.TopItem = LVI;
                lvwClients.EnsureVisible(lvwClients.Items.Count - 1);
                Application.DoEvents();
                i++;
            }
        }

        private void btnUpdate_Click(object sender, System.EventArgs e)
        {
            clients = Server.clientsList;
            List<string> cList = clients.Keys.OfType<string>().ToList();
            lvwClients.Clear();
            ListViewItem listyviewsy = new ListViewItem();
            foreach (string elem in cList)
            {
                lvwClients.Items.Add(new ListViewItem(elem));
            }
        }
    }
}
